home *** CD-ROM | disk | FTP | other *** search
/ The Best of MacTutor - S…e Code for Volumes 1 to 5 / The Best of MacTutor - Source Code for Volume 1-5 (Wayzata Technology)(6031)(1990).bin / Source Code / #44 (May 89) / Cursor Stuff / AnimCurs.c < prev    next >
Text File  |  1989-02-17  |  18KB  |  399 lines

  1. /*    Animated Cursor subroutines.
  2.  
  3.         Copyright © 1989 by Michael S. Morton, all rights reserved.
  4.         Written February ’89 for MacTutor.  Feel free to use these or
  5.         modify them so long as the original author and source are noted.
  6.  
  7.         Routines included are:
  8.         • acStartHG -- set the cursor to be an hourglass
  9.         • acStartW1, acStartW2 -- set the cursor to be a 1- or 2-handed watch
  10.         • acDelay -- set the delay, in ticks, between animation steps
  11.         • acNext -- idle-time routine 
  12.  
  13.         To set up any of these cursors, call the acStart___ routine, passing the
  14.         delay you’d like between frames.  Then call acNext during your idle
  15.         routine.  To change the delay, call acDelay.  To get a different kind
  16.         of cursor, stop calling acNext and use SetCursor to get it.
  17. */
  18.  
  19. /*    State information for three cursor types: */
  20. typedef struct                                                    /* info on the HOURGLASS: */
  21. {    long coin;                                                        /* used in random number generator */
  22.     int grainRow;                                                    /* row number (0…15) of falling grain */
  23.     int grainBit;                                                    /* bit mask for falling grain */
  24.     Boolean grainMoving;                                    /* flag: is the grain still moving? */
  25. } hourInfo;                                                            /* define this type */
  26.  
  27. typedef struct                                                    /* info on ONE-HANDED WATCH: */
  28. {    int wFrame;                                                        /* which frame of animation are we on? */
  29. } watch1Info;                                                        /* define this type */
  30.  
  31. typedef struct                                                    /* info on TWO-HANDED WATCH: */
  32. {    int mFrame;                                                        /* frame of minute hand */
  33.     int hFrame;                                                        /* frame of hour hand */
  34. } watch2Info;                                                        /* define this type */
  35.  
  36. /*    Generalized cursor type: */
  37. typedef enum
  38. { hgType, w1Type, w2Type } cursType;        /* selects one of above structs */
  39.  
  40. typedef struct                                                    /* tracks any kind of cursor */
  41. {    Cursor curs;                                                    /* current cursor */
  42.     int delay;                                                        /* delay between frames (ticks) */
  43.     long nextFrame;                                                /* time of next frame (ticks) */
  44.     cursType type;                                                /* type of cursor */
  45.     union                                                                    /* depending on type of cursor: */
  46.     {    hourInfo hg;                                                /*  • info on hourglass */
  47.         watch1Info w1;                                            /*  • info on one-handed watch */
  48.         watch2Info w2;                                            /*  • info on two-handed watch */
  49.     } u;                                                                    /* give union an easy name */
  50. } cursInfo, *ciPtr;
  51.  
  52. /*    The cursor information is used globally all through this file. */
  53. cursInfo theInfo;                                                /* sole instance of this struct */
  54.  
  55. /*    16x16 data and masks for cursors.  Some of these are OR’d together to
  56.         make the two-handed watch.  Others are just backgrounds which are
  57.         drawn on, such as for the hourglass. */
  58. int hourData [16] =                                            /* hourglass, about to start falling */
  59.     {    0xFFFE, 0x7FFC, 0x7FFC, 0x7FFC, 0x5FF4, 0x4FE4, 0x47C4, 0x4384,
  60.         0x4284, 0x46C4, 0x4C64, 0x5834, 0x701C, 0x600C, 0x4004, 0xFFFE };
  61. int hourMask [16] = 
  62.     { 0xFFFE, 0x7FFC, 0x7FFC, 0x7FFC, 0x5FF4, 0x4FE4, 0x47C4, 0x4384,
  63.         0x4384, 0x47C4, 0x4FE4, 0x5FF4, 0x7FFC, 0x7FFC, 0x7FFC, 0xFFFE };
  64.  
  65. int watchMask [16] =
  66.     {    0x3E00, 0x3E00, 0x3E00, 0x3E00, 0x7F00, 0xFF80, 0xFF80, 0xFFC0,
  67.         0xFFC0, 0xFF80, 0x7F00, 0x3E00, 0x3E00, 0x3E00, 0x3E00, 0x0000 };
  68.  
  69. int watchMinutes [12][16] =                            /* twelve minute-hand positions */
  70. {
  71.     { 0x3E00, 0x3E00, 0x3E00, 0x3E00, 0x4900, 0x8880, 0x8880, 0x88C0,
  72.         0x80C0, 0x8080, 0x4100, 0x3E00, 0x3E00, 0x3E00, 0x3E00, 0x0000 },
  73.     { 0x3E00, 0x3E00, 0x3E00, 0x3E00, 0x4300, 0x8480, 0x8480, 0x88C0,
  74.         0x80C0, 0x8080, 0x4100, 0x3E00, 0x3E00, 0x3E00, 0x3E00, 0x0000 },
  75.     { 0x3E00, 0x3E00, 0x3E00, 0x3E00, 0x4100, 0x8180, 0x8680, 0x88C0,
  76.         0x80C0, 0x8080, 0x4100, 0x3E00, 0x3E00, 0x3E00, 0x3E00, 0x0000 },
  77.     { 0x3E00, 0x3E00, 0x3E00, 0x3E00, 0x4100, 0x8080, 0x8080, 0x8FC0,
  78.         0x80C0, 0x8080, 0x4100, 0x3E00, 0x3E00, 0x3E00, 0x3E00, 0x0000 },
  79.     { 0x3E00, 0x3E00, 0x3E00, 0x3E00, 0x4100, 0x8080, 0x8080, 0x88C0,
  80.         0x86C0, 0x8180, 0x4100, 0x3E00, 0x3E00, 0x3E00, 0x3E00, 0x0000 },
  81.     { 0x3E00, 0x3E00, 0x3E00, 0x3E00, 0x4100, 0x8080, 0x8080, 0x88C0,
  82.         0x84C0, 0x8480, 0x4300, 0x3E00, 0x3E00, 0x3E00, 0x3E00, 0x0000 },
  83.     { 0x3E00, 0x3E00, 0x3E00, 0x3E00, 0x4100, 0x8080, 0x8080, 0x88C0,
  84.         0x88C0, 0x8880, 0x4900, 0x3E00, 0x3E00, 0x3E00, 0x3E00, 0x0000 },
  85.     { 0x3E00, 0x3E00, 0x3E00, 0x3E00, 0x4100, 0x8080, 0x8080, 0x88C0,
  86.         0x90C0, 0x9080, 0x6100, 0x3E00, 0x3E00, 0x3E00, 0x3E00, 0x0000 },
  87.     { 0x3E00, 0x3E00, 0x3E00, 0x3E00, 0x4100, 0x8080, 0x8080, 0x88C0,
  88.         0xB0C0, 0xC080, 0x4100, 0x3E00, 0x3E00, 0x3E00, 0x3E00, 0x0000 },
  89.     { 0x3E00, 0x3E00, 0x3E00, 0x3E00, 0x4100, 0x8080, 0x8080, 0xF8C0,
  90.         0x80C0, 0x8080, 0x4100, 0x3E00, 0x3E00, 0x3E00, 0x3E00, 0x0000 },
  91.     { 0x3E00, 0x3E00, 0x3E00, 0x3E00, 0x4100, 0xC080, 0xB080, 0x88C0,
  92.         0x80C0, 0x8080, 0x4100, 0x3E00, 0x3E00, 0x3E00, 0x3E00, 0x0000 },
  93.     { 0x3E00, 0x3E00, 0x3E00, 0x3E00, 0x6100, 0x9080, 0x9080, 0x88C0,
  94.         0x80C0, 0x8080, 0x4100, 0x3E00, 0x3E00, 0x3E00, 0x3E00, 0x0000 }
  95. };
  96.  
  97. int watchHours [8][16] =                                /* eight hour-hand positions */
  98. {
  99.     {    0x3E00, 0x3E00, 0x3E00, 0x3E00, 0x4100, 0x8880, 0x8880, 0x8880,
  100.         0x8080, 0x8080, 0x4100, 0x3E00, 0x3E00, 0x3E00, 0x3E00, 0x0000 },
  101.     {    0x3E00, 0x3E00, 0x3E00, 0x3E00, 0x4100, 0x8080, 0x8480, 0x8880,
  102.         0x8080, 0x8080, 0x4100, 0x3E00, 0x3E00, 0x3E00, 0x3E00, 0x0000 },
  103.     {    0x3E00, 0x3E00, 0x3E00, 0x3E00, 0x4100, 0x8080, 0x8080, 0x8E80,
  104.         0x8080, 0x8080, 0x4100, 0x3E00, 0x3E00, 0x3E00, 0x3E00, 0x0000 },
  105.     {    0x3E00, 0x3E00, 0x3E00, 0x3E00, 0x4100, 0x8080, 0x8080, 0x8880,
  106.         0x8480, 0x8080, 0x4100, 0x3E00, 0x3E00, 0x3E00, 0x3E00, 0x0000 },
  107.     {    0x3E00, 0x3E00, 0x3E00, 0x3E00, 0x4100, 0x8080, 0x8080, 0x8880,
  108.         0x8880, 0x8880, 0x4100, 0x3E00, 0x3E00, 0x3E00, 0x3E00, 0x0000 },
  109.     {    0x3E00, 0x3E00, 0x3E00, 0x3E00, 0x4100, 0x8080, 0x8080, 0x8880,
  110.         0x9080, 0x8080, 0x4100, 0x3E00, 0x3E00, 0x3E00, 0x3E00, 0x0000 },
  111.     {    0x3E00, 0x3E00, 0x3E00, 0x3E00, 0x4100, 0x8080, 0x8080, 0xB880,
  112.         0x8080, 0x8080, 0x4100, 0x3E00, 0x3E00, 0x3E00, 0x3E00, 0x0000 },
  113.     {    0x3E00, 0x3E00, 0x3E00, 0x3E00, 0x4100, 0x8080, 0x9080, 0x8880,
  114.         0x8080, 0x8080, 0x4100, 0x3E00, 0x3E00, 0x3E00, 0x3E00, 0x0000 }
  115. };
  116.  
  117. /*    Function prototypes for stuff we define externally: */
  118. #include "AnimCurs.h"
  119.  
  120. /*    Function prototypes for our static stuff: */
  121. void acStartW (cursType type, int delay); /* start either kind of watch */
  122. void copy16 (int *src, Bits16 *dst);        /* copy a 16x16 bit image */
  123. void or16 (int *src, Bits16 *dst);            /*   OR a 16x16 bit image */
  124. void hideGrain (void);                                    /* hide current grain in hourglass */
  125. void showGrain (void);                                    /* show current grain in hourglass */
  126. Boolean coinFlip (void);                                /* produce a pseudo-random boolean */
  127. void stealGrain (void);                                    /* remove a grain from top section */
  128. void dropGrain (void);                                    /* get a grain moving */
  129. void moveGrain (int dh, int dv);                /* move a grain in transit */
  130. void nextHour (void);                                        /* compute next cursor: hourglass */
  131. void nextWatch (void);                                    /*                                            watch */
  132. void nextWatch2 (void);                                    /*                                            2-handed watch */
  133. void doNextFrame (void);                                /* compute next frame and show it */
  134.  
  135.  
  136. /*    acStartHG () -- Initialize the hourglass cursor, with the specified delay
  137.         between animation frames.  This is an external routine. */
  138. void acStartHG (delay)
  139.     int delay;                                                        /* INPUT: pause between frames */
  140. {    theInfo.delay = delay;                                /* record delay in structure */
  141.     theInfo.nextFrame = TickCount () + delay; /* figure when to animate next */
  142.     theInfo.type = hgType;                                /* remember the type: hourglass */
  143.     theInfo.u.hg.grainRow = -1;                        /* make a grain drop in dropGrain () */
  144.  
  145.     /*    Initialize cursor data, mask and hotspot (altho dropGrain does data, too) */
  146.     copy16 (hourData, & (theInfo.curs.data));    
  147.     copy16 (hourMask, & (theInfo.curs.mask));
  148.     theInfo.curs.hotSpot.v = 8;                        /* stick hotspot… */
  149.     theInfo.curs.hotSpot.h = 8;                        /* …in middle */
  150.  
  151.     dropGrain ();                                                    /* start first grain dropping */
  152. }                                                                                /* end of acStartHG () */
  153.  
  154. /*    acStartW1 () -- Just like acStartHG, but with a one-handed watch.
  155.         This is an external routine.
  156. */
  157. void acStartW1 (delay)
  158.     int delay;                                                        /* INPUT: pause between frames */
  159. {    acStartW (w1Type, delay);
  160. }                                                                                /* end of acStartW1 () */
  161.  
  162. /*    acStartW2 () -- Just like acStartHG, but with a two-handed watch.
  163.         This is an external routine.
  164. */
  165. void acStartW2 (delay)
  166.     int delay;                                                        /* INPUT: pause between frames */
  167. {    acStartW (w2Type, delay);
  168. }                                                                                /* end of acStartW2 () */
  169.  
  170. /*    acStartW () -- Start a one- or two-handed watch. */
  171. static void acStartW (type, delay)
  172.     cursType type;                                                /* INPUT: w1Type or w2Type */
  173.     int delay;                                                        /* INPUT: pause between frames */
  174. {    theInfo.delay = delay;                                /* record delay in structure */
  175.     theInfo.nextFrame = TickCount () + delay; /* figure when to animate next */
  176.     theInfo.type = type;                                /* remember the type */
  177.  
  178.     if (type == w1Type)                                        /* init different types: */
  179.         theInfo.u.w1.wFrame = 0;                        /* one-handed: set frame to zero */
  180.     else
  181.     {    theInfo.u.w2.mFrame = 0;                        /* two-handed: set minute frame… */
  182.         theInfo.u.w2.hFrame = 0; }                    /* …and hour frame to zero */
  183.  
  184.     /*    Initialize the cursor data, mask and hotspot: */
  185.     copy16 (watchMinutes [0], & (theInfo.curs.data));
  186.     copy16 (watchMask, & (theInfo.curs.mask));
  187.     theInfo.curs.hotSpot.v = 8;                        /* stick hotspot… */
  188.     theInfo.curs.hotSpot.h = 8;                        /* …in middle */
  189. }                                                                                /* end of acStartW () */
  190.  
  191. /*    copy16 () -- Copy an array of 16 ints into a Bits16 structure (the data
  192.         or mask of a cursor. */
  193. void copy16 (src, bits)
  194.     register int *src;                                        /* INPUT: source data */
  195.     Bits16 *bits;                                                    /* OUTPUT: where to stuff it */
  196. {    register int *dst = (int *) bits;            /* coerce to a handier data type */
  197.     int i;                                                                /* FORTRAN-ish loop counter */
  198.  
  199.     for (i = 0; i <= 15; i++) *dst++ = *src++; /* copy 16 words */
  200. }                                                                                /* end of copy16 () */
  201.  
  202. /*    or16 () -- Just like copy16(), but we OR, not COPY. */
  203. void or16 (src, bits)
  204.     register int *src;                                        /* INPUT: source data */
  205.     Bits16 *bits;                                                    /* OUTPUT: where to stuff it */
  206. {    register int *dst = (int *) bits;            /* coerce to a handier data type */
  207.     int i;                                                                /* FORTRAN-ish loop counter */
  208.  
  209.     for (i = 0; i <= 15; i++) *dst++ |= *src++; /* OR 16 words */
  210. }                                                                                /* end of or16 () */
  211.  
  212. /*    hideGrain () -- Hide the pixel where the current grain is. */
  213. static void hideGrain ()
  214. {    theInfo.curs.data [theInfo.u.hg.grainRow] &=
  215.         (~ theInfo.u.hg.grainBit);
  216. }
  217.  
  218. /*    showGrain () -- Show the pixel where the current grain is. */
  219. static void showGrain ()
  220. {    theInfo.curs.data [theInfo.u.hg.grainRow] |=
  221.         theInfo.u.hg.grainBit;
  222. }
  223.  
  224. /*    coinFlip () -- Return a pseudo-random boolean value.  We use a shift-
  225.         register system detailed in Knuth, among other places. */
  226. static Boolean coinFlip ()
  227. {    register Boolean result;
  228.  
  229.     if (! theInfo.u.hg.coin)                            /* zero? */
  230.         theInfo.u.hg.coin = 1;                            /* avoid demon state */
  231.     result = (theInfo.u.hg.coin < 0);            /* note if high bit is set */
  232.  
  233.     theInfo.u.hg.coin <<= 1;                            /* shift old value over 1 bit… */
  234.     if (result)                                                        /* …and if top bit was ‘1’… */
  235.         theInfo.u.hg.coin ^= 0xc5;                    /* …then futz with low bits */
  236.  
  237.     return (result);
  238. }                                                                                /* end of coinFlip () */
  239.  
  240. /*    stealGrain -- Grab a grain of sand from the top chamber of the hourglass.
  241.         We want to percolate a white pixel up from the starting bit position. */
  242. static void stealGrain ()
  243. {    register int v = 6;                                        /* start at row 6, tip of top half */
  244.     register int hBit = 0x0100;                        /* start at the middle */
  245.     register Boolean done = false;                /* haven’t finished percolating yet */
  246.     register int aboveWord;                                /* row of sand grains above us */
  247.     register Boolean leftOK, rightOK;            /* are there bits to steal above? */
  248.  
  249.     while (! done)
  250.     {    --v;                                                                /* assume we can move up a row */
  251.         aboveWord = theInfo.curs.data [v];    /* get that row from the cursor image */
  252.  
  253.         /*    Decide which direction to steal from -- if there's a grain right above
  254.                 us, we’ll take that.  Otherwise, we have to choose between the ones
  255.                 diagonally up from us. */
  256.         if ((aboveWord & hBit) == 0)                /* have a bit above us? */
  257.         {    leftOK = (0 != (aboveWord & (hBit << 1))); /* have someone above on left? */
  258.             rightOK = (0 != (aboveWord & (hBit >> 1))); /* someone above on right? */
  259.  
  260.             /*    Branch, depending on which way(s) we can go: */
  261.             if (leftOK && rightOK)                        /* both available? */
  262.             {    if (coinFlip ()) hBit <<= 1;        /* yes: flip a coin… */
  263.                 else hBit >>= 1;                                /* …to decide */
  264.             }
  265.             else if (leftOK) hBit <<= 1;            /* just left: take it */
  266.             else if (rightOK) hBit >>= 1;            /* just right: take it */
  267.             else { ++v; done = true; }                /* neither: back down */
  268.         }                                                                        /* end of no bit above us */
  269.  
  270.         if (v <= 1) done = true;                        /* if we hit top row, we have to stop */
  271.     }                                                                            /* end of while-not-done */
  272.  
  273.     theInfo.curs.data [v] &= (~ hBit);        /* snuff this bit */
  274. }                                                                                /* end of stealGrain () */
  275.  
  276. /*    dropGrain () -- Get next grain of sand to fall.  The “moving” flag is false.
  277.  
  278.         We get one grain of sand from the top chamber.  If the bottom chamber is
  279.         filled, we reinit the cursor to a full top chamber.  Either way, we flag
  280.         that a grain is moving, and draw it.
  281. */
  282. static void dropGrain ()
  283. {    stealGrain ();                                                /* pull a grain from the top chamber */
  284.  
  285.     /*    If the pile in the bottom chamber has filled it, the most recent
  286.             grain dropped didn’t get very far. */
  287.     if (theInfo.u.hg.grainRow < 9)                /* are we piled too high? */
  288.         copy16 (hourData, & (theInfo.curs.data));    /* yes: redraw all */
  289.  
  290.     theInfo.u.hg.grainRow = 8;            /* set row number of new grain */
  291.     theInfo.u.hg.grainBit = 0x0100;                /* set bit in row */
  292.     theInfo.u.hg.grainMoving = true;            /* we’re cooking with gas now */
  293.     showGrain ();                                                    /* show the grain */
  294. }                                                                                /* end of dropGrain () */
  295.  
  296. /*    moveGrain () -- Move the current grain by a given delta.  Note that a
  297.         positive “dh” is a right shift. */
  298. static void moveGrain (dh, dv)
  299.     int dh, dv;                                                        /* INPUT: amount to move by */
  300. {    hideGrain ();                                                    /* hide where it is now */
  301.  
  302.     theInfo.u.hg.grainRow += dv;                    /* update vertical position */
  303.     if (dh > 0)                                                        /* update horizontal position */
  304.         theInfo.u.hg.grainBit >>= dh;
  305.     else theInfo.u.hg.grainBit <<= -dh;
  306.  
  307.     showGrain ();                                                    /* show where it is now */
  308. }                                                                                /* end of moveGrain () */
  309.  
  310. /*    nextHour () -- Advance the hourglass by one frame. */
  311. static void nextHour ()
  312. {    register int v, hBit;                                    /* coordinate and bit pos of grain */
  313.     register int nextWord;                                /* word of grains below us */
  314.     register Boolean leftOK, rightOK;            /* flags for OK directions to fall */
  315.  
  316.     if (! theInfo.u.hg.grainMoving)                /* grain hit bottom last time? */
  317.         dropGrain ();                                                /* yes: get a new one */
  318.  
  319.     v = theInfo.u.hg.grainRow;                        /* grab position and bit just… */
  320.     hBit = theInfo.u.hg.grainBit;                    /* …for easier typing & efficiency */
  321.  
  322.     nextWord = theInfo.curs.data [v+1];        /* get word below this one */
  323.     if ((nextWord & hBit) == 0)                        /* slot below us free? */
  324.     {    moveGrain (0, 1);                                        /* yes: just move down one */
  325.         return;                                                            /* and that’s all we need */
  326.     }
  327.  
  328.     leftOK = (0 == (nextWord & (hBit << 1))); /* have nobody below on left? */
  329.     rightOK = (0 == (nextWord & (hBit >> 1))); /* nobody below on right? */
  330.  
  331.     /*    Branch, depending on which way(s) we can go: */
  332.     if (leftOK && rightOK)                                /* can fall left or right? */
  333.     {    if (coinFlip ())                                        /* yes: randomly choose: */
  334.             moveGrain (1, 1);                                    /*  • fall to the right */
  335.         else moveGrain (-1, 1);                            /*  • fall to the left */
  336.     }
  337.     else if (leftOK) moveGrain (-1, 1);        /* left only: do it */
  338.     else if (rightOK) moveGrain (1, 1);        /* right only: do it */
  339.     else theInfo.u.hg.grainMoving = false; /* can’t move: stop; reset next time */
  340. }                                                                                /* end of nextHour () */
  341.  
  342. /*    nextWatch -- Compute the next frame of one-handed watch animation. */
  343. static void nextWatch ()
  344. {    ++ theInfo.u.w1.wFrame;                                /* bump frame ahead by 1 */
  345.     if ((theInfo.u.w1.wFrame) >= 12)            /* outside of range 0…11? */
  346.         theInfo.u.w1.wFrame = 0;                        /* yes: wrap around */
  347.  
  348.     copy16 (watchMinutes [theInfo.u.w1.wFrame],
  349.                     & (theInfo.curs.data));
  350. }                                                                                /* end of nextWatch () */
  351.  
  352. /*    nextWatch2 -- Compute the next frame of two-handed watch animation. */
  353. static void nextWatch2 ()
  354. {    ++ theInfo.u.w2.mFrame;                                /* bump MINUTE frame ahead by 1 */
  355.     if ((theInfo.u.w2.mFrame) >= 12)            /* outside of range 0…11? */
  356.         theInfo.u.w2.mFrame = 0;                        /* yes: wrap around */
  357.  
  358.     copy16 (watchMinutes [theInfo.u.w2.mFrame],
  359.                     & (theInfo.curs.data));
  360.  
  361.     if (theInfo.u.w2.mFrame == 0)                    /* MINUTE frame just hit 12 o’clock? */
  362.     {    ++ theInfo.u.w2.hFrame;                            /* yes: bump HOUR frame ahead by 1 */
  363.         if ((theInfo.u.w2.hFrame) >= 8)            /* outside of range 0…7? */
  364.             theInfo.u.w2.hFrame = 0;                    /* yes: wrap around */
  365.     }
  366.  
  367.     /*    Add hour-hand image into minute-hand. */
  368.     or16 (watchHours [theInfo.u.w2.hFrame],
  369.                     & (theInfo.curs.data));
  370. }                                                                                /* end of nextWatch () */
  371.  
  372. /*    doNextFrame -- Compute next frame, dispatching on type of cursor. */
  373. static void doNextFrame ()
  374. {    switch (theInfo.type)
  375.     {    case hgType:    nextHour ();        break;
  376.         case w1Type:    nextWatch ();        break;
  377.         case w2Type:    nextWatch2 ();    break;
  378.         default:                                            break;
  379.     }                                                                            /* end of switch on cursor type */
  380. }                                                                                /* end of doNextFrame () */
  381.  
  382. /*    acNext -- Idle-time animation.  This is an external routine.
  383. */
  384. void acNext ()
  385. {    if (TickCount () < theInfo.nextFrame)    /* time to animate yet? */
  386.         return;                                                            /* nope: return */
  387.  
  388.     theInfo.nextFrame = TickCount () + theInfo.delay; /* reset wake-up call */
  389.     doNextFrame ();                                                /* draw next frame internally */
  390.     SetCursor (& (theInfo.curs));                    /* and display it */
  391. }                                                                                /* end of acNext () */
  392.  
  393. /*    acDelay -- Set delay, in ticks, between frames.  This is an external routine.
  394. */
  395. void acDelay (delay)
  396.     int delay;                                                        /* INPUT: new delay */
  397. {    theInfo.delay = delay;
  398.     theInfo.nextFrame = TickCount () + delay; /* figure when to animate next */
  399. }                                                                                /* end of acDelay () */